<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;

/**
 * App\BuildMatch
 *
 * @mixin \Eloquent
 * @property int $id
 * @property string|null $name 配套名称
 * @property string|null $icon 图标
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\BuildMatch whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\BuildMatch whereIcon($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\BuildMatch whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\BuildMatch whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\BuildMatch whereUpdatedAt($value)
 */
class BuildMatch extends Model
{
    //
    protected $table = "build_match";
    public static function getSelectOptions()
    {
        $options = \DB::table('build_match')->select('id','name as text')->get();
        $selectOption = [];
        foreach ($options as $option){
            $selectOption[$option->id] = $option->text;
        }
        return $selectOption;
    }
    public function getIconAttribute($v){
        if (!strpos('http',$v)){
            return Storage::url($v).'?imageView2/0/w/100/h/100';
        }else{
            return $v.'?imageView2/0/w/100/h/100';
        }
    }
}
